<?php
/**
 * 
 * Email deliver
 * Example:
 * $mail = new Zend_Mail();
 * $mail->setSubject('subject')
 * 		->setBodyHtml('html content')
 * 		->addTo('email');
 *		
 * $emailSender = new Nutri_Email_EmailSender();
 * $emailSender->sendEmail($mail);
 *
 */
class Nutri_Email_EmailSender {
	
	protected $_transport = null;
	
	/**
	 * 
	 * set the transport usin email smtp conbfiguration.
	 */
	public function __construct()
	{
		$config = Zend_Registry::get('config');
		$smpt = $config->smtp;
		if (!empty($smpt)) {
			$this->_transport = new Zend_Mail_Transport_Smtp($config->smtp->server, $config->smtp->config->toArray());
		}	
	}
	/**
	 * 
	 * send email
	 * @param Zend_Mail $mail
	 * @return Zend_Mail;
	 */
	public function sendEmail(Zend_Mail $mail)
	{
		return $mail->send($this->_transport);
	}
}